﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;

namespace AvalonDock.BindingSample
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            this.DataContext = this;

        }

        private void OnAddItem(object sender, RoutedEventArgs e)
        {
            SampleCollection.Add("NewItem " + (SampleCollection.Count + 1));
        }


        #region SampleCollection

        /// <summary>
        /// SampleCollection Dependency Property
        /// </summary>
        public static readonly DependencyProperty SampleCollectionProperty =
            DependencyProperty.Register("SampleCollection", typeof(ObservableCollection<string>), typeof(MainWindow),
                new FrameworkPropertyMetadata((ObservableCollection<string>)new ObservableCollection<string>()));

        /// <summary>
        /// Gets or sets the SampleCollection property. 
        /// </summary>
        public ObservableCollection<string> SampleCollection
        {
            get { return (ObservableCollection<string>)GetValue(SampleCollectionProperty); }
            set { SetValue(SampleCollectionProperty, value); }
        }

        #endregion

        private void OnCanExecuteMyCommand(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = true;
        }

        private void OnExecutedMyCommand(object sender, ExecutedRoutedEventArgs e)
        {
            MessageBox.Show("My Command!");
        }
    }
}
